/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
/*
 * TrainingBook
 * Copyright (C) Arnaud Duval 2010 <arnaud.duval@gmail.com>
 * 
 * TrainingBook is free software: you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * TrainingBook is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "osm-map-bounding-box.hpp"

#include <cmath>



///@brief Default constructor
OsmMapBoundingBox::OsmMapBoundingBox()
{
	minLat = 0.;
	maxLat = 0.;
	minLon = 0.;
	maxLon = 0.;
}

///@brief Constructor with arguments
///@param DminLat Minimum value of latitude IN DEGREES
///@param DmaxLat Maximum value of latitude IN DEGREES
///@param DminLon Minimum value of longitude IN DEGREES
///@param DmaxLon Maximum value of longitude IN DEGREES
OsmMapBoundingBox::OsmMapBoundingBox(double DminLat, double DmaxLat,
									double DminLon, double DmaxLon)
{
	minLat = DminLat * M_PI/180.;
	maxLat = DmaxLat * M_PI/180.;
	minLon = DminLon * M_PI/180.;
	maxLon = DmaxLon * M_PI/180.;
}

///@brief Desctructor
OsmMapBoundingBox::~OsmMapBoundingBox()
{

}

///@brief Return minimum latitude
double OsmMapBoundingBox::GetMinLat()
{
	return minLat;
}

///@brief Return maximum latitude
double OsmMapBoundingBox::GetMaxLat()
{
	return maxLat;
}

///@brief Return minimum longitude
///@return Value of the minimum longitude
double OsmMapBoundingBox::GetMinLon()
{
	return minLon;
}

///@brief Return maximum longitude
///@return Value of the maximum longitude
double OsmMapBoundingBox::GetMaxLon()
{
	return maxLon;
}

///@brief Set the minimum latitude
///@param DminLat Minimum value of latitude
void OsmMapBoundingBox::SetMinLat(double DminLat)
{
	minLat = DminLat;
}

///@brief Set the maximum latitude
///@param DmaxLat Maximum value of latitude
void OsmMapBoundingBox::SetMaxLat(double DmaxLat)
{
	maxLat = DmaxLat;
}

///@brief Set the minimum longitude
///@param DminLon Minimum value of longitude
void OsmMapBoundingBox::SetMinLon(double DminLon)
{
	minLon = DminLon;
}

///@brief Set the maximum longitude
///@param DmaxLon Maximum value of longitude
void OsmMapBoundingBox::SetMaxLon(double DmaxLon)
{
	maxLon = DmaxLon;
}

///@brief Return the latitude of the center of the bouding box
double OsmMapBoundingBox::GetCenterLat()
{
	return (minLat + maxLat)/2.;
}

///@brief Return the longitude of the center of the bouding box
double OsmMapBoundingBox::GetCenterLon()
{
	return (minLon + maxLon)/2.;
}

///@brief Translate the bounding box
///@param dLon Longitude increment IN RADIANS
///@param dLat Latitude increment IN RADIANS
void OsmMapBoundingBox::Translate(double dLon, double dLat)
{
	minLon += dLon;
	maxLon += dLon;
	minLat += dLat;
	maxLat += dLat;
}



